package cn.polymhomework01;

public class Test {
    public static void main(String[] args) {
        Animal a = new Cat();
        a = new Dog();
        a.eat();
        a = new Eagle();
        a.eat();
        Eagle eagle = (Eagle) a;
        eagle.eagleHunt();
        ((Eagle) a).eagleHunt();

        System.out.println("---------------------");



        Animal[] animal= new Animal[3];
        animal[0] = new Dog();
        animal[1] = new Cat();
        animal[2] = new Eagle();
        for (Animal d : animal) {
            if (d instanceof Dog) {
                ((Dog) d).lookHouse();
            }
            if (d instanceof Cat) {
                ((Cat) d).catchMouse();
            }
            if (d instanceof Eagle) {
                ((Eagle) d).eagleHunt();
            }
        }

    }
}